CC = gcc
#CFLAGS2 = -O2 -Wall
#CFLAGS = -Wreturn-type -Wno-pointer-sign -Wunused-variable
#OSFLAGS = -DNO_REST_HTTP_SERVER -DNO_QSORT_R
CFLAGS = -Wall -DNO_REST_HTTP_SERVER -DNO_QSORT_R -DINSERT_LIBUUID $(MYCFLAGS)
COMPILE = $(CC) $(CFLAGS) $(OSFLAGS)  -c 
REST_LIBS = -llua -lexpat
LIBS = -levent -lm -lpthread -lcrypto -luuid $(MYLIBS)
OBJFILES := $(patsubst %.c,%.o,$(wildcard *.c))

all: edb

# linux requires: libossp-uuid-dev; _GNU_SOURCE is defined to get pread/pwrite defined but
# #define _XOPEN_SOURCE 500 
# should be defined instead but this breaks libevent's includes apparently
linux:
	$(MAKE) all MYCFLAGS="-D_GNU_SOURCE `/usr/bin/uuid-config --cflags`" MYLIBS="`/usr/bin/uuid-config --ldflags --libs`"

clean:
	-rm *.o
	-rm edb

test: edb
	cd test; ./test.sh

edb: $(OBJFILES)
	$(CC) -Wall $(LIBS) -L/usr/local/lib -o edb $(OBJFILES)

%.o: %.cpp
	$(COMPILE) -o $@ $<